<?php
/******************************************************************************
 *
 *                Bridge Health Monitoring (BHM) System  - Rama8
 *
 ******************************************************************************
 * FileName:        realtime.php
 * Processor:        gerneral computer
 * Dependencies:  None
 * Compiler:         PHP: 5.4.7
 * Develop by:		 Thammasak Sa-nguansatwaja
 * Version:         0.1.0
 *
 * Software License  for  	IMMS Co., Ltd.  ,http://www.immsgroup.com/
 *  0.0.6    tcp socket, Disconnected Oriented Concept
 *  0.1.0,   tcp socket ,Connected  Oriented  Concept
 * 
 */

/**  
	
   
**/
ob_start();
//	$host='tcp://192.168.1.36';
//	$host='tcp://192.168.55.240';
	$host='tcp://127.0.0.1';
	$port=1007;
	$ReadSize=1000;
	//echo "Connect to server \n";
	//--------  get data from Sock  -------------------------
	$fp = fsockopen($host,$port,$errno,$errstr);
	if (!$fp) {
		echo "$errstr ($errno)<br />\n";
	} else {
		while(1){
			$sockDATA= fread($fp,$ReadSize);		
			if((strlen($buffDATA.$sockDATA))>$ReadSize){
					$buffDATA="";
			}
			$buffDATA.=$sockDATA;
			//echo $SDATA_SOCK;
			if(strlen($buffDATA)>0){
				alert $buffDATA;
			}else{
				echo "";
			}
		}
//		fclose($fp);
	}

//-------------------------------------------------------
ob_end_flush(); 
?>